﻿#region Using

using System;
using System.Reflection;
using Vk.Authorization;

#endregion

namespace Vk
{
    /// <summary>
    ///     Vkontakte API instance
    /// </summary>
    public class Api
    {
        private readonly VkSession _session;
        private RequestManager _manager;

        /// <summary>
        ///     API version (the same as the assembly's version)
        /// </summary>
        public static string Version => Assembly.GetExecutingAssembly().GetName().Version.ToString(2);

        /// <summary>
        ///     Обьект для осуществления запросов к API
        /// </summary>
        internal RequestManager Manager
        {
            get { return _manager ?? (_manager = new RequestManager(_session)); }
            private set { _manager = value; }
        }

        /// <summary>
        /// All methods will be available
        /// </summary>
        /// <param name="session">A valid auth. session</param>
        public Api(VkSession session)
        {
            if (!session.IsValid())
            {
                throw new ArgumentException("Session should be valid.");
            }
            _session = session;
        }

        /// <remarks>
        ///     Only open methods will be available
        /// </remarks>
        public Api()
        {
        }
    }
}